<template>
    <div class="page-container">
        <!-- 轮播图部分 -->
        <div class="carousel-section">
            <el-carousel height="500px" indicator-position="outside" arrow="always">
                <el-carousel-item v-for="(img, index) in carouselImages" :key="index">
                    <div class="carousel-content" :style="{ backgroundImage: `url(${img})` }">
                        <div class="carousel-overlay">
                            <h2 class="carousel-title">欢迎来到奕飞酒店</h2>
                            <p class="carousel-subtitle">享受舒适住宿体验</p>
                        </div>
                    </div>
                </el-carousel-item>
            </el-carousel>
        </div>
        
        <!-- 客房展示部分 -->
        <div class="section room-section">
            <div class="section-header">
                <h2 class="section-title">精选客房</h2>
                <p class="section-subtitle">为您提供多种舒适的住宿选择</p>
            </div>
            <div class="section-list">
                <div v-for="item in categoryList" 
                     :key="item.id" 
                     class="room-card" 
                     @click="$router.push(`/front/room?categoryId=${item.id}`)">
                    <div class="room-image" :style="{ backgroundImage: `url(${$baseFileUrl+item.photo})` }">
                        <div class="room-price">￥{{ item.price }}<span>/晚</span></div>
                    </div>
                    <div class="room-info">
                        <h3 class="room-title">{{ item.categoryName }}</h3>
                        <el-button type="primary" size="small" class="book-btn">立即预订</el-button>
                    </div>
                </div>
            </div>
        </div>

        <!-- 酒店简介部分 -->
        <div class="section intro-section">
            <div class="section-header">
                <h2 class="section-title">关于我们</h2>
                <p class="section-subtitle">奕飞酒店 - 您的理想之选</p>
            </div>
            <div class="hotel-introduction">
                <div class="intro-content">
                    <div class="intro-text">
                        <div class="intro-block">
                            <h3 class="intro-title">酒店简介</h3>
                            <p>上海奕飞酒店集团旗下新创的一个酒店业品牌，第一家门店位于市中心黄金地段。从酒店到外滩、陆家嘴、人民广场和豫园只有几分钟的步行路程。</p>
                            <p>在这里您尽可体验淮海路繁华商业与城隍庙传统文化的交织融汇，百分百感受东方巴黎—上海的时代脉搏。</p>
                            <p>酒店拥有200间精心设计的客房，配备现代化设施，为宾客提供舒适便捷的住宿体验。周边交通便利，距离地铁站仅需步行3分钟，是商务出行和休闲旅游的理想选择。</p>
                        </div>
                        
                        <div class="intro-block">
                            <h3 class="intro-title">设计理念</h3>
                            <p>酒店按照当下风靡世界的"BOUTIQUEHOTEL"风格设计，以现代欧版为基调，所配置的设施与服务也力求时尚与快捷。每个房间都经过精心设计，融合了现代艺术与东方元素，为您带来独特的视觉享受。</p>
                            <p>设计师巧妙地将传统中式元素与现代简约风格相结合，客房内采用柔和的灯光设计，搭配精选的家具和艺术品，让每位宾客都能感受到家的温暖。</p>
                        </div>

                        <div class="intro-block">
                            <h3 class="intro-title">服务特色</h3>
                            <p>我们提供24小时管家服务，专业的礼宾团队随时为您解决各种需求。酒店配备高端健身中心、SPA会所、商务会议室等设施，满足您的各种需求。</p>
                            <p>酒店拥有一支经验丰富的服务团队，每位员工都经过专业培训，能够为宾客提供贴心周到的服务。从前台接待到客房服务，我们致力于为每位宾客创造难忘的住宿体验。</p>
                        </div>

                        <div class="intro-features">
                            <div class="feature">
                                <i class="el-icon-location"></i>
                                <span>便捷位置</span>
                                <p>市中心黄金地段，交通便利</p>
                            </div>
                            <div class="feature">
                                <i class="el-icon-star-on"></i>
                                <span>优质服务</span>
                                <p>24小时管家服务，专业团队</p>
                            </div>
                            <div class="feature">
                                <i class="el-icon-picture"></i>
                                <span>精致环境</span>
                                <p>现代艺术与东方元素融合</p>
                            </div>
                            <div class="feature">
                                <i class="el-icon-food"></i>
                                <span>美食体验</span>
                                <p>米其林星级餐厅，特色美食</p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="intro-images">
                    <div class="image-container main-image">
                        <img src="@/assets/introduce.jpeg" alt="酒店介绍" />
                        <div class="image-overlay">
                            <div class="overlay-content">
                                <h3>尊享奢华体验</h3>
                                <p>尽在奕飞酒店</p>
                            </div>
                        </div>
                    </div>
                    <div class="image-container secondary-image">
                        <img src="@/assets/eat.jpg" alt="餐厅大堂" />
                        <div class="image-overlay">
                            <div class="overlay-content">
                                <h3>元素西餐</h3>
                                <p>欢迎光临</p>
                            </div>
                        </div>
                    </div>
                    <div class="image-container secondary-image">
                        <img src="@/assets/cafe.jpg" alt="咖啡厅" />
                        <div class="image-overlay">
                            <div class="overlay-content">
                                <h3>悠闲咖啡</h3>
                                <p>尽享舒适</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 最新公告部分 -->
        <div class="section notice-section">
            <div class="section-header">
                <h2 class="section-title">最新公告</h2>
                <p class="section-subtitle">了解酒店最新动态</p>
            </div>
            <el-table 
                :data="noticeList" 
                border 
                fit 
                highlight-current-row 
                class="notice-table">
                <el-table-column 
                    align="center" 
                    label="公告编号" 
                    prop="id" 
                    width="100">
                </el-table-column>
                <el-table-column 
                    align="left" 
                    label="公告标题" 
                    prop="title" 
                    show-overflow-tooltip>
                </el-table-column>
                <el-table-column 
                    align="center" 
                    label="发布时间" 
                    prop="createTime" 
                    width="180">
                </el-table-column>
                <el-table-column 
                    fixed="right" 
                    label="操作" 
                    width="100" 
                    align="center">
                    <template slot-scope="scope">
                        <el-button 
                            @click="$router.push(`/front/noticeDetails/${scope.row.id}`)" 
                            type="primary" 
                            size="mini">
                            查看详情
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
        </div>
    </div>
</template>

<script>
import { getTop5NoticeAPI } from '@/api/notice'
import { findAllCategoryAPI } from '@/api/category'

export default {
    name: 'Hotely5dWebHome',

    data() {
        return {
            noticeList: [],
            categoryList: [],
            carouselImages: [
                require('@/assets/introduction.jpg'),
                require('@/assets/jiudian2.jpg'),
                require('@/assets/houtai.jpg')
            ]
        };
    },

    async mounted() {
        try {
            const [noticeRes, categoryRes] = await Promise.all([
                getTop5NoticeAPI(),
                findAllCategoryAPI()
            ]);
            
            this.noticeList = noticeRes.data || [];
            this.categoryList = categoryRes.data || [];
        } catch (error) {
            console.error('Error fetching data:', error);
            this.$message.error('获取数据失败，请稍后重试');
        }
    }
};
</script>

<style lang="less" scoped>
@deep-bg: linear-gradient(135deg, #232946 0%, #393e46 100%);
@gold: #ffd700;
@main-blue: #409EFF;
@light-gray: #bbb;

.page-container {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0;
    overflow: hidden;
    background: @deep-bg;
}

// 轮播图部分
.carousel-section {
    margin-bottom: 60px;

    .carousel-content {
        height: 100%;
        background-size: cover;
        background-position: center;
        position: relative;
        border-radius: 18px;
        overflow: hidden;
        box-shadow: 0 4px 24px rgba(0,0,0,0.18);

        .carousel-overlay {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.35);
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            color: @gold;
            text-align: center;

            .carousel-title {
                font-size: 48px;
                font-weight: 600;
                margin-bottom: 20px;
                text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
            }

            .carousel-subtitle {
                font-size: 24px;
                color: #fff;
                text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
            }
        }
    }
}

.gold-text {
    color: @gold !important;
}
.gold-bg {
    background: @gold !important;
    color: #232946 !important;
    font-weight: bold;
}
.gold-btn {
    background: @gold !important;
    border-color: @gold !important;
    color: #232946 !important;
    font-weight: bold;
}
.gold-btn:hover {
    filter: brightness(1.1);
    color: #232946 !important;
}

// 通用section样式
.section {
    padding: 60px 20px;
    margin-bottom: 40px;
    border-radius: 18px;
    background: rgba(35,41,70,0.92);
    box-shadow: 0 4px 24px rgba(0,0,0,0.10);

    .section-header {
        text-align: center;
        margin-bottom: 40px;

        .section-title {
            font-size: 36px;
            font-weight: 600;
            margin: 0 0 15px;
            color: @light-gray;
        }

        .section-subtitle {
            font-size: 18px;
            color: @light-gray;
            margin: 0;
        }
    }
}

// 客房展示部分
.room-section {
    background: rgba(35,41,70,0.92);

    .section-list {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 30px;
        padding: 0 20px;
    }

    .room-card {
        background: #232946;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
        transition: transform 0.3s ease, box-shadow 0.3s;
        border: 1.5px solid @gold;

        &:hover {
            transform: translateY(-5px) scale(1.03);
            box-shadow: 0 8px 32px rgba(0,0,0,0.22);
        }

        .room-image {
            height: 250px;
            background-size: cover;
            background-position: center;
            position: relative;

            .room-price {
                position: absolute;
                right: 20px;
                bottom: 20px;
                background: @gold;
                padding: 8px 16px;
                border-radius: 20px;
                color: #232946;
                font-weight: bold;
                font-size: 20px;
                box-shadow: 0 2px 8px #0002;

                span {
                    font-size: 14px;
                    margin-left: 4px;
                }
            }
        }

        .room-info {
            padding: 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;

            .room-title {
                margin: 0;
                font-size: 18px;
                color: @gold;
            }
        }
    }
}

// 酒店简介部分
.intro-section {
    background: rgba(35,41,70,0.92);
    .hotel-introduction {
        display: flex;
        gap: 50px;
        align-items: center;
        padding: 0 20px;

        @media (max-width: 1024px) {
            flex-direction: column;
        }

        .intro-content {
            flex: 1;

            .intro-text {
                .intro-block {
                    margin-bottom: 30px;
                    padding: 20px;
                    background: rgba(255,255,255,0.05);
                    border-radius: 12px;
                    border: 1px solid rgba(255,215,0,0.1);
                    transition: all 0.3s ease;

                    &:hover {
                        transform: translateY(-5px);
                        box-shadow: 0 8px 24px rgba(0,0,0,0.2);
                        border-color: rgba(255,215,0,0.3);
                    }

                    .intro-title {
                        color: @gold;
                        font-size: 24px;
                        margin-bottom: 15px;
                        font-weight: 600;
                        position: relative;
                        padding-left: 15px;

                        &::before {
                            content: '';
                            position: absolute;
                            left: 0;
                            top: 50%;
                            transform: translateY(-50%);
                            width: 4px;
                            height: 24px;
                            background: @gold;
                            border-radius: 2px;
                        }
                    }

                    p {
                        font-size: 16px;
                        line-height: 1.8;
                        color: @light-gray;
                        margin-bottom: 15px;
                        text-align: justify;

                        &:last-child {
                            margin-bottom: 0;
                        }
                    }
                }

                .intro-features {
                    display: grid;
                    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
                    gap: 30px;
                    margin-top: 40px;

                    .feature {
                        text-align: center;
                        padding: 25px 20px;
                        background: rgba(255,255,255,0.05);
                        border-radius: 12px;
                        border: 1px solid rgba(255,215,0,0.1);
                        transition: all 0.3s ease;

                        &:hover {
                            transform: translateY(-5px);
                            box-shadow: 0 8px 24px rgba(0,0,0,0.2);
                            border-color: rgba(255,215,0,0.3);
                        }

                        i {
                            font-size: 36px;
                            color: @gold;
                            margin-bottom: 15px;
                        }

                        span {
                            display: block;
                            font-size: 18px;
                            color: @gold;
                            font-weight: 600;
                            margin-bottom: 10px;
                        }

                        p {
                            font-size: 14px;
                            color: @light-gray;
                            margin: 0;
                            line-height: 1.6;
                        }
                    }
                }
            }
        }

        .intro-images {
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 20px;

            .image-container {
                position: relative;
                border-radius: 12px;
                overflow: hidden;
                box-shadow: 0 4px 24px rgba(0,0,0,0.2);
                transition: all 0.3s ease;

                &:hover {
                    transform: translateY(-5px);
                    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
                }
                
                img {
                    width: 100%;
                    height: auto;
                    display: block;
                    transition: transform 0.3s ease;
                }

                .image-overlay {
                    position: absolute;
                    bottom: 0;
                    left: 0;
                    right: 0;
                    padding: 20px;
                    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
                    color: #fff;
                    text-align: center;

                    .overlay-content {
                        h3 {
                            font-size: 20px;
                            margin-bottom: 5px;
                            color: @gold;
                        }

                        p {
                            font-size: 14px;
                            margin: 0;
                            opacity: 0.9;
                        }
                    }
                }

                &:hover img {
                    transform: scale(1.05);
                }
            }

            .main-image {
                flex: 2;
            }

            .secondary-image {
                flex: 1;
            }
        }
    }
}

// 最新公告部分
.notice-section {
    background: rgba(35,41,70,0.92);

    .notice-table {
        background: #232946;
        border-radius: 8px;
        overflow: hidden;
        box-shadow: 0 2px 12px 0 rgba(0,0,0,0.18);
        border: 1.5px solid @gold;

        /deep/ .el-table__header-wrapper {
            th {
                background-color: #232946;
                color: @gold;
                font-weight: 600;
            }
        }

        /deep/ .el-table__row {
            background: #232946 !important;
            color: #fff !important;
        }
        /deep/ .el-table__cell {
            color: #fff !important;
        }
        /deep/ .el-table__row:hover {
            background: #393e46 !important;
        }
        /deep/ .el-button--mini {
            padding: 7px 15px;
            background: @gold !important;
            border-color: @gold !important;
            color: #232946 !important;
            font-weight: bold;
        }
        /deep/ .el-button--mini:hover {
            filter: brightness(1.1);
            color: #232946 !important;
        }
    }
}

// 响应式调整
@media (max-width: 768px) {
    .carousel-section {
        .carousel-content {
            .carousel-overlay {
                .carousel-title {
                    font-size: 32px;
                }
                .carousel-subtitle {
                    font-size: 18px;
                }
            }
        }
    }

    .section {
        padding: 40px 15px;

        .section-header {
            .section-title {
                font-size: 28px;
            }
            .section-subtitle {
                font-size: 16px;
            }
        }
    }
}
</style>